package com.hd.openapi.servies.serviceimpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hd.openapi.common.ResponseResult;
import com.hd.openapi.common.ResultTable;
import com.hd.openapi.dao.ApiMappingMapper;
import com.hd.openapi.entity.AdminUser;
import com.hd.openapi.entity.ApiMapping;
import com.hd.openapi.servies.appmapperser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class appmapperserimpl implements appmapperser {
    @Autowired
    private ApiMappingMapper am;

    @Override
    public ResultTable getalldata(Integer page, Integer limit,
                                  String gatewayApiName, String state) {
        PageHelper.startPage (page,limit);
       List<ApiMapping> a=am.getalldata(gatewayApiName,state);
        PageInfo b=new PageInfo (a);
        return new ResultTable (0,"",(int)b.getTotal (),b.getList ());
    }

    @Override
    public ResponseResult deldata(Integer[] ids) {
        return  am.deldata(ids);
    }

    @Override
    public ResponseResult adddata(ApiMapping adminUser) {
        int i = am.insertSelective (adminUser);
        return ResponseResult.getSuccess ();
    }

    @Override
    public ResponseResult updatedata(ApiMapping apiMapping) {
        int i = am.updateByPrimaryKeySelective (apiMapping);
        return ResponseResult.getSuccess ();
    }
}
